package com.ck.design.monitor;

/**
 * 观察者模式
 * @author timiv
 */
public class Main {

    public static void main(String[] args) {
        Person person = new Person("ck");

        person.registerListener(new PersonListener() {
            @Override
            public void eat(Event event) {
                System.out.println(event.getResource().getName() + "正在吃饭！");
            }

            @Override
            public void sleep(Event event) {
                System.out.println(event.getResource().getName() + "正在睡觉！");
            }
        });
        person.sleep();

    }
}
